package com.byt.framlib.basemvp.exception;

import androidx.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;


/**
 * 自定义错误code类型:注解写法
 * <p>
 * 可自由扩展
 * Created by WZG on 2016/12/12.
 */

public class CodeException {

    /*网络错误*/
    public static final int NETWORD_ERROR = 0x1;
    /*http_错误*/
    public static final int HTTP_ERROR = 0x2;
    /*fastjson错误*/
    public static final int JSON_ERROR = 0x3;
    /*未知错误*/
    public static final int UNKNOWN_ERROR = 0x4;
    /*运行时异常-包含自定义异常*/
    public static final int RUNTIME_ERROR = 0x5;
    /*无法解析该域名*/
    public static final int UNKOWNHOST_ERROR = 0x6;

    /*超时错误*/
    public static final int TIMEOUT_ERROR = 0x7;

    @IntDef({NETWORD_ERROR, HTTP_ERROR, RUNTIME_ERROR, UNKNOWN_ERROR, JSON_ERROR, UNKOWNHOST_ERROR, TIMEOUT_ERROR})
    @Retention(RetentionPolicy.SOURCE)

    public @interface CodeEp {

    }

  /*  public static String getApiExceptionMessage(int code) {
        switch (code) {
            case NETWORD_ERROR:
                return "网络异常,请检查网络";
            case HTTP_ERROR:
                return "接口出错,请检查链接";
            case JSON_ERROR:
                return "数据出错,解析失败";
            case UNKNOWN_ERROR:
                return "未知错误,请联系管理员";
            case RUNTIME_ERROR:
                return "运行异常,请联系程序员";
            case UNKOWNHOST_ERROR:
                return "无法解析域名,请联系管理员";
            case TIMEOUT_ERROR:
                return "网络连接超时,请稍后在再尝试";
            default:
                return "服务器异常,请联系管理员";
        }
    }*/
}
